<?php
/**
 * Created by PhpStorm.
 * User: 明哲
 * Date: 2016/6/3
 * Time: 9:32
 */
include('../../config.php');

$action = $_GET['action'];
$del_id = $_GET['id'];

switch ($action) {
    default:
        $row = $mysql->query("select *  from `video` where `id`='{$del_id}'");
        if($row){
            echo json_encode($row[0],true);
        }else{
            echo 0;
        };
        break;
    case 'del' :
        $rows = $mysql->query("delete from `video` where `id`='{$del_id}'");
        echo 1;
        break;
    case 'update' :
        $id = $_GET['id'];
        $category_id = $_GET['category_id'];
        $title = $_GET['title'];
        $slogan = $_GET['slogan'];
        $detail = $_GET['detail'];
        $label = $_GET['label'];
        $img_url = $_GET['img_url'];
        $video_url = $_GET['video_url'];
        $rows = $mysql->query("update `video` set `category_id`='{$category_id}',`title`='{$title}',`slogan`='{$slogan}',`detail`='{$detail}',`label`='{$label}',`img_url`='{$img_url}',`video_url`='{$video_url}' where `id`='{$id}'");
        if(!$rows){
            echo 1;
        }else{
            echo 0;
        }
        break;

}